//
//  JXHEmoticon.swift
//  emojeTest
//
//  Created by juxiaohui on 16/11/1.
//  Copyright © 2016年 juxiaohui. All rights reserved.
//

import UIKit

class JXHEmoticon: NSObject {

    var code : String? {
        didSet{
            guard let code = code else {
                return
            }
            //创建扫描器
            let scanner = Scanner.init(string: code)
            
            //调用方法,扫描出code中的值
            var value : UInt32 = 0
            
            scanner.scanHexInt32(&value)
            
            //将value转成字符
            let c = Character.init(UnicodeScalar.init(value)!)
            //将字符转为字符串
            emojiCode = String.init(c)
        }
    }
    
    var png : String? {
        didSet{
            guard let png = png else {
                return
            }
            pngPath = Bundle.main.bundlePath + "/Emoticons.bundle/" + png
        }
    }
    
    var chs : String?
    
    // MARK: - 数据处理
    var pngPath : String?
    var emojiCode : String?
    var isRemove : Bool = false
    var isEmpty : Bool = false
    
    init(dic : [String : String]) {
        
        super.init()
        
        setValuesForKeys(dic)
    }
    
    init(isRemove : Bool) {
        
        self.isRemove = isRemove
    }
    
    init(isEmpty : Bool) {
        
        self.isEmpty = isEmpty
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
    }
}
